package 笔试.斗鱼;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

/**
 * @author:谢君臣
 * @Date:2021/8/29-18:44
 * @version:1.0
 * @function:
 */
public class Main {
    public static void main(String[] args) {
        int[] ints = diff_elements(new int[]{1, 2, 3, 4, 5, 6}, new int[]{4, 5});
        System.out.println(ints);
    }
    public static int[] diff_elements(int[]a,int[]b ){
        HashSet<Integer> hashSet = new HashSet<>();
        List<Integer> list = new ArrayList<>();
        for (int i : b) {
            hashSet.add(i);
        }
        for (int num : a) {
            if (!hashSet.contains(num)) list.add(num);
        }
        int []res = new int[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return  res;
    }
}
